import { createApp } from 'vue';
import { createPinia } from 'pinia';
import ArcoVue from '@arco-design/web-vue';
import ArcoVueIcon from '@arco-design/web-vue/es/icon';
import globalComponents from '@/components';
import globalMethods from '@/utils';
import addUserRoutes from './router/guard/userRouter'
import router from './router';
import i18n from './locale';
import directive from './directive';
//import './mock'; // 注释掉mock 影响下载时候的response type，如用demo代码 可以放开。
import './router/guard/permission' // permission control
import App from './App.vue';
// Styles are imported via arco-plugin. See config/plugin/arcoStyleImport.ts in the directory for details
// 样式通过 arco-plugin 插件导入。详见目录文件 config/plugin/arcoStyleImport.ts
// https://arco.design/docs/designlab/use-theme-package
import '@/assets/style/global.less';
import '@/api/interceptor';

const app = createApp(App);
const pinia = createPinia();
app.use(pinia)

// 刷新页面时候 注入路由
const loadRouter = async () => {
    await addUserRoutes();
}

const init = async () => {
    await loadRouter();

    app.use(ArcoVue, {});
    app.use(ArcoVueIcon);
    app.use(router);
    app.use(i18n);
    // 注册全局组件
    app.use(globalComponents);
    // 注册全局方法
    app.use(globalMethods);
    app.use(directive);

    app.mount('#app');
}

init();

